﻿using System;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Windows.Threading;

using Xc.DataAccess.Core.Services;
using Xc.DataAccess.HyperTerminalCore.Models;

namespace Xc.DataAccess.HyperTerminalCore.Services
{
    /// <summary>
    /// UDP服务端配置信息
    /// </summary>
    public class UdpServerOption : DeviceIdBase
    {
        int port;
        /// <summary>
        /// 监听的端口
        /// </summary>
        public int Port
        {
            get => port;
            set
            {
                if (port == value)
                {
                    return;
                }

                port = value;
                RaisedPropertyChanged();
            }
        }
        /// <summary>
        /// 编码方式
        /// </summary>
        [JsonIgnore]
        public Encoding Encoding { get; set; } =new HexEncoding();
        /// <summary>
        /// 句柄线程
        /// </summary>
        [JsonIgnore]
        public Dispatcher Dispatcher { get; set; }
        TimeSpan timeOut = TimeSpan.FromSeconds(10);
        /// <summary>
        /// 超时值
        /// </summary>
        public TimeSpan TimeOut
        {
            get => timeOut;
            set
            {
                if (timeOut == value)
                {
                    return;
                }

                timeOut = value;
                RaisedPropertyChanged();
            }
        }
    }

}
